package com.hgyc.mom.tool.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hgyc.mom.tool.service.AutoCodePartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.hgyc.mom.tool.mapper.AutoCodeRuleMapper;
import com.hgyc.mom.tool.entity.AutoCodeRule;
import com.hgyc.mom.tool.service.AutoCodeRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import com.hgyc.mom.common.exception.BizException;

/**
 * 编码生成规则Service业务层实现
 *
 * @author fwj
 * @since 2025-05-06
 */
@Slf4j
@Service
public class AutoCodeRuleServiceImpl extends ServiceImpl<AutoCodeRuleMapper, AutoCodeRule> implements AutoCodeRuleService {

    @Autowired
    public AutoCodePartService autoCodePartService;

    @Override
    public AutoCodeRule getByCode(String ruleCode) {
        LambdaQueryWrapper<AutoCodeRule> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AutoCodeRule::getRuleCode, ruleCode);
        return getOne(queryWrapper, false);
    }

    @Override
    public void removeCodeRule(List<Long> ids) {
        // TODO 其他逻辑
        removeByIds(ids);
        //删除包装物料信息
        autoCodePartService.deleteBatchByParentIds(ids);
    }
}
